/**************************************************************************************************
  Filename:       Dataservice.h
  Revised:        $Date: 2013-09-05 15:48:17 -0700 (Thu, 05 Sep 2013) $
  Revision:       $Revision: 35223 $

  Description:    Data service definitions and prototypes

**************************************************************************************************/

#ifndef DATASERVICE_H
#define DATASERVICE_H

#ifdef __cplusplus
extern "C"
{
#endif

/*********************************************************************
 * INCLUDES
 */

/*********************************************************************
 * CONSTANTS
 */

// Data Service Parameters
#define DATA_PACK                       0      // RW uint8 - Profile Attribute value
#define DATA_ACK                        1      // RW uint8 - Profile Attribute value
#define DATA_CTRL                       2
// Service UUID
#define DATA_SERV_UUID                  0xAA50 // 0000FFF0-0451-4000-B000-00000000-0000
#define DATA_PACK_UUID                  0xAA51
#define DATA_ACK_UUID                   0xAA52
#define DATA_CTRL_UUID                  0xAA53
// Default passcode
#define MAXTAIN_PASSCODE                19637
// Data Profile Services bit fields
#define DATA_SERVICE                    0x00000101

  
#define DATA_STOP_TRANSFER                0
#define DATA_START_TRANSFER               1
  
// Data Pack Length
#define DATA_PACK_LEN              		13

  
#define DATA_PACK_CONFIG_NO_OP          0x06
#define DATA_PACK_CONFIG_SET_NOTIFY     0x07
#define DATA_PACK_RECEIVED              0x08
#define DATA_ACK_RECEIVED               0x09
#define DATA_CTRL_RECEIVED              0x0A
#define DATACTRL_GET_USERPAGE 			0x0B
#define DATACTRL_GET_SECUPAGE 			0x0C
#define DATACTRL_GET_SETTINGPAGE 		0x0D
 
#define DATACTRL_GOTO_OAD				0xEE


#define DATACTRL_SYNCREADY 				0x22
#define DATACTRL_OPENREALTIME                           0x23
/*********************************************************************
 * TYPEDEFS
 */

/*********************************************************************
 * MACROS
 */

/*********************************************************************
 * Profile Callbacks
 */
/*********************************************************************
 * Profile Callbacks
 */

// Callback when a characteristic value has changed
typedef void (*dataChange_t)( uint8 paramID );

typedef struct
{
  dataChange_t        pfnDatahange;  // Called when characteristic value changes
} dataCBs_t;


/*********************************************************************
 * API FUNCTIONS
 */

/*
 * Data_AddService- Initializes the Data Profile service by registering
 *          GATT attributes with the GATT server.
 *
 * @param   services - services to add. This is a bit map and can
 *                     contain more than one service.
 */
extern bStatus_t Data_AddService( uint32 services );

/*
 * Data_RegisterAppCBs - Registers the application callback function.
 *                    Only call this function once.
 *
 *    appCallbacks - pointer to application callbacks.
 */
extern bStatus_t Data_RegisterAppCBs( dataCBs_t *appCallbacks );
extern bStatus_t Data_EnableNotify(uint16 centBLEConnHandle);
/*
 * Data_SetParameter - Set a Data Profile parameter.
 *
 *    param - Profile parameter ID
 *    len - length of data to right
 *    pValue - pointer to data to write.  This is dependent on
 *          the parameter ID and WILL be cast to the appropriate
 *          data type (example: data type of uint16 will be cast to
 *          uint16 pointer).
 */
extern bStatus_t Data_SetParameter( uint8 param, uint8 len, void *pValue );

/*
 * Data_GetParameter - Get a Data Profile parameter.
 *
 *    param - Profile parameter ID
 *    pValue - pointer to data to write.  This is dependent on
 *          the parameter ID and WILL be cast to the appropriate
 *          data type (example: data type of uint16 will be cast to
 *          uint16 pointer).
 */
extern bStatus_t Data_GetParameter( uint8 param, void *pValue );


extern bStatus_t DataPack_Notify(uint16 connHandle,void *value);

/*********************************************************************
*********************************************************************/

#ifdef __cplusplus
}
#endif

#endif /* DataPROFILE_H */
